$(function () {
    vue.APIaddress=vue.getCookie("APIaddress");
    vue.data=vue.getCookie("data");
})
var vue=new Vue({
    el:'#cqr',
    data:{
        APIaddress:'',
        data:'',
        type:'POST',
        dataType:"JSON",
        message:''
    },
    methods:{
        submit:function () {
            vue.setCookie("APIaddress",vue.APIaddress,3);
            vue.setCookie("data",vue.data,3);
            $.ajax({
                type:vue.type,
                url:"../"+vue.APIaddress,
                data:vue.data,
                dataType:vue.dataType,
                success:function (message) {
                    vue.message=message;
                },
                error:function (message) {
                    vue.message="errorFunctionPrint:"+message;
                }
            });
        },
        getCookie:function (name) {
            var arr;
            var reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
            if (arr = document.cookie.match(reg))
                return unescape(arr[2]);
            else
                return null;
        },
        setCookie:function (name, value, day) {
            if(day !== 0){     //当设置的时间等于0时，不设置expires属性，cookie在浏览器关闭后删除
                var expires = day * 24 * 60 * 60 * 1000;
                var date = new Date(+new Date()+expires);
                document.cookie = name + "=" + escape(value) + ";expires=" + date.toUTCString();
            }else{
                document.cookie = name + "=" + escape(value);
            }
        }
    }
});